#pragma once

#include "UMLStyle.h"


namespace uml {

const QString UMLStyle::fontName_default_ = "";
const double UMLStyle::fontSize_default_ = 0.0;
UMLStyle::UMLStyle(const QString& umlType)
    : PackageableElement(umlType) {}

void UMLStyle::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    PackageableElement::fromJson(json, errorList);
    fontName_ = json.value("fontName").toString(fontName_default_);
    fontSize_ = json.value("fontSize").toDouble(fontSize_default_);
}

void UMLStyle::toJson(QJsonObject& json) {
    PackageableElement::toJson(json);
    if (fontName_ != fontName_default_) {
        json.insert("fontName", fontName_);
    }
    if (fontSize_ != fontSize_default_) {
        json.insert("fontSize", fontSize_);
    }
}

/// <summary>
/// fontName getter
/// Name of a font used to render strings.
/// </summary>
QString UMLStyle::fontName() const {
    return fontName_;
}

/// <summary>
/// fontName setter
/// Name of a font used to render strings.
/// </summary>
void UMLStyle::setFontName(const QString& value) {
    fontName_ = value;
}

/// <summary>
/// fontSize getter
/// Size of a font for rendering strings, given in typographical points.
/// </summary>
double UMLStyle::fontSize() const {
    return fontSize_;
}

/// <summary>
/// fontSize setter
/// Size of a font for rendering strings, given in typographical points.
/// </summary>
void UMLStyle::setFontSize(double value) {
    fontSize_ = value;
}

} // namespace uml
